#ifndef CAMERA_H
#define CAMERA_H

#include <QObject>
#include <QTimer>
#include <QMap>
#include <QDebug>
#include <QImage>
#include "image_det.h"
#include "common.h"

#define CAMERA_FPS 30 //30hz, 考虑计算还需要时间




/*--------------视觉部分--------------*/
struct CamParam{
    int A[8];
    int B[8];
    int C;
    int D;
};

int H_Mid2_CV_det(cv::Mat& frame_data,const CamParam& cam, bool& result_img); //result_img: 1-没料，0-有料
int C_Mid1_CV_det(cv::Mat& frame_data,const CamParam& cam, bool& result_img);

/*--------------视觉部分--------------*/


class Camera : public QObject
{
    Q_OBJECT
public:
    explicit Camera(const int& index, const CamParam& param, QObject *parent = nullptr);
    ~Camera();

    void Open();


signals:
    void show_camera(const int& index, const QImage& img);

private:
    int _camera_index;
    cv::VideoCapture* _camera;
    QTimer* _camera_timer;
    CamParam _camera_param;

private slots:
    void Work();

public slots:
    void UpdateParam(const CamParam& param);
};

#endif // CAMERA_H
